package com.suse.lhw.hms.foodserver.service.Impl;

import com.suse.lhw.hms.foodserver.constant.CollectionConst;
import com.suse.lhw.hms.foodserver.dao.FFoodmodelMapper;
import com.suse.lhw.hms.foodserver.dao.FPackageMapper;
import com.suse.lhw.hms.foodserver.domin.FFoodmodel;
import com.suse.lhw.hms.foodserver.domin.FPackage;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import com.suse.lhw.hms.foodserver.dao.FCollectionMapper;
import com.suse.lhw.hms.foodserver.domin.FCollection;
import com.suse.lhw.hms.foodserver.service.FCollectionService;

import java.util.ArrayList;
import java.util.List;

/**
 * @ProjectName: health_manage_system
 * @Package: com.suse.lhw.hms.foodserver.service.Impl
 * @ClassName: FCollectionServiceImpl
 * @Description: java类作用描述
 * @Author: 李鸿炜
 * @CreateDate: 2020/5/3 0:29
 * @UpdateUser: 更新者
 * @UpdateDate: 2020/5/3 0:29
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
@Service
public class FCollectionServiceImpl implements FCollectionService {

    @Resource
    private FCollectionMapper fCollectionMapper;
    @Resource
    private FPackageMapper fPackageMapper;
    @Resource
    private FFoodmodelMapper fFoodmodelMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return fCollectionMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(FCollection record) {
        return fCollectionMapper.insert(record);
    }

    @Override
    public int insertSelective(FCollection record) {
        return fCollectionMapper.insertSelective(record);
    }

    @Override
    public FCollection selectByPrimaryKey(Integer id) {
        return fCollectionMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(FCollection record) {
        return fCollectionMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(FCollection record) {
        return fCollectionMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<FPackage> selectAllByType() {
        List<FCollection> fCollection = fCollectionMapper.selectAllByType(CollectionConst.PACKAGE);
        List<FPackage> list = new ArrayList<FPackage>();
        for (FCollection collection : fCollection) {
            FPackage fPackage = fPackageMapper.selectByPrimaryKey(collection.getCollectionid());
            list.add(fPackage);
        }
        return list;
    }

    @Override
    public List<FFoodmodel> selectALLModelCollection() {

        List<FCollection> fcOllection = fCollectionMapper.selectAllByType(CollectionConst.MODEL);
        List<FFoodmodel> list = new ArrayList<FFoodmodel>();
        for (FCollection fCollection : fcOllection) {
            FFoodmodel fFoodmodel = fFoodmodelMapper.selectByPrimaryKey(fCollection.getCollectionid());
            list.add(fFoodmodel);
        }
        return list;
    }

}
